<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <base target="_self"/>
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var stateValue="";
    $().ready(function(){
            
			var options = {
		  	    url:'<%=request.getContextPath() %>/weituodan!updateGuzhang.action',
		  	     beforeSubmit: function() {
		   				return checking();
		    			},
		  	    dataType:'json',
		  	    success: function(data) {
		  	    //alert(data);
		  	      if(data.result=='success'){
					alert("保存成功");
				//	window.close();
					api.close();
					W.gridSearchGuzhang();
		  	      }
		  	    }};
		$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 });
    	$('#closeBtn').click(function(){
    		api.close();
			//window.close();
		});
		
	});
	
   	function checking(){
   		var flag = true;
		var CHXINGNAME = $.trim($("#CHXINGNAME").val());
		var FENLEINAME = $.trim($("#FENLEINAME").val());
		var XITONGNAME = $.trim($("#XITONGNAME").val());
		var LINGBUJIANNAME = $.trim($("#LINGBUJIANNAME").val());
		var GUZHANGPATTERNNAME = $.trim($("#GUZHANGPATTERNNAME").val());
		if(CHXINGNAME ==null || CHXINGNAME == "" ){
			alert("车型不能为空！");
			$("#CHXINGNAME").focus();
    		return false;
		}
		if(FENLEINAME == null || FENLEINAME == ""){
			alert("分类不能为空！");
			$("#FENLEINAME").focus();
    		return false;
		}
		if(XITONGNAME == null || XITONGNAME == ""){
			alert("子系统不能为空！");
			$("#XITONGNAME").focus();
    		return false;
		}
		if(LINGBUJIANNAME == null || LINGBUJIANNAME == ""){
			alert("零部件不能为空！");
			$("#LINGBUJIANNAME").focus();
    		return false;
		}
		if(GUZHANGPATTERNNAME == null || GUZHANGPATTERNNAME == ""){
			alert("故障模式不能为空！");
			$("#GUZHANGPATTERNNAME").focus();
    		return false;
		}
		
	}
	 
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
			return false;
		}
		return true;
	}
	function checkNum(inputData){
		var sNumber;
	    sNumber=Number(inputData);
	    if (isNaN(inputData)){
	       return false;
	     }
	    return true;
	}
	function countlen1(textarea){
	       var elem = event.relatedTarget || event.srcElement || event.target ||event.currentTarget;    
	        if(event.keyCode!=8)
			{
			  if (textarea.value.length> 249){
			        alert("最多为250个字符,字符输入超出限制!");
			        textarea.value=textarea.value.substring(0,249);
			    }
			    return true;
	 	    }
	}
	
	function changevalue(id){
	 	
	 	var flag = "0";
	 	if(id == 1){
	 		var fileValue = document.getElementById("file1").value;
	 		var a=fileValue.lastIndexOf("\\");
	 		var filename = fileValue.substring(a+1);
			document.getElementById("gongyingshangzizhi").value=filename;
			flag = "1";
		}else if(id == 2){
		    var fileValue = document.getElementById("file2").value;
	 		var a=fileValue.lastIndexOf("\\");
	 		var filename = fileValue.substring(a+1);
			document.getElementById("gongyingshangpingjia").value=filename;
			flag = "2";
		}
		document.getElementById("flag").value=flag;
	}
	//选择
	//参数信息：表明，关联列，显示列
	function selectData(id,tablename,colname,disname,cnname,fieldslist,formid){
	    var fileColname ='hideFileName';
	    if(tablename=='DIC_STANDARD'){
	      fileColname = "YCLJS_GYYW";
	    }
	    var   datas = window.showModalDialog("<%=request.getContextPath() %>/auto!chooseDatalist.action?byTableValueId=null&tablename="+tablename+"&colname="+colname+"&disname="+disname+"&cnname="+escape(encodeURIComponent(cnname))+"&fileColname="+fileColname+"&formid="+formid+"&fileName="+id+"&temp="+Math.round(Math.random()*10000),'',"dialogWidth=800px;dialogHeight=500px");
	       if(typeof(datas) == 'undefined'){
		   }else{
			 var json1 = eval('(' + datas + ')');
			 document.getElementById(id).value = json1.ID;
			
			 var disnamearray = disname.split(',');
			if(formid=='4424'){//整车可靠性试验流程  添加故障页面
				if(id=='FENLEI'){//车型
			 		document.getElementById("FENLEINAME").value = json1[disnamearray[0]];
			 	}else
			 	if(id=='CHEXING'){//车型
			 		document.getElementById("CHXINGNAME").value = json1[disnamearray[0]];
			 	}else if(id=='ZIXITONG'){//子系统
			 		document.getElementById("XITONGNAME").value = json1[disnamearray[0]];
			 	}else if(id=='LINGBUJIAN'){//零部件
			 		document.getElementById("LINGBUJIANNAME").value = json1[disnamearray[0]];
			 	}else if(id=='GUZHANGPATTERN'){//故障模式
			 		document.getElementById("GUZHANGPATTERNNAME").value = json1[disnamearray[0]];
			 	}
			 }
			 else{
			    document.getElementById("data_"+id).value = json1.NAME;
			   if (fieldslist!=undefined){
			 	var fieldslistarray = fieldslist.split(',');
			 	for(var i=0;i<fieldslistarray.length;i++){
			 		if (i==0){
			 			document.getElementById("data_"+id).value = json1[disnamearray[0]];
			 		}
			 		if(fieldslistarray[i] == "COUNT"){
			 			$('#COUNT').numberbox('setValue', json1[disnamearray[i]]);
			 		}else{
			 			document.getElementById(fieldslistarray[i]).value = json1[disnamearray[i]];
			 		}
			 	}
			   }
			   else{
			 	document.getElementById("data_"+id).value = json1[disnamearray[0]];
			   }
			}
			 
			 
		  }
	}
	//选择零部件
	function selectLBJ(){
		var XITONGNAME = $.trim($("#XITONGNAME").val());
		if(XITONGNAME == null || XITONGNAME == ""){
			alert("请先选择子系统！");
			$("#XITONGNAME").focus();
    		return false;
		}
	    var zixitongId = $('#ZIXITONG').val();
		var   datas = window.showModalDialog("<%=request.getContextPath() %>/view/choose_lingbujian.jsp?flag=1&zixitongId="+zixitongId,'',"dialogWidth=800px;dialogHeight=500px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("LINGBUJIAN").value = json1.id;
			 document.getElementById("LINGBUJIANNAME").value = json1.name;
		}
	}
	//選擇子系統
	function selectZixitong(){
		var FENLEINAME = $.trim($("#FENLEINAME").val());
		if(FENLEINAME == null || FENLEINAME == ""){
			alert("请先选择分类！");
			$("#FENLEINAME").focus();
    		return false;
		}
	    var zixitongId = $('#FENLEI').val();
		var   datas = window.showModalDialog("<%=request.getContextPath() %>/view/choose_lingbujian.jsp?flag=0&zixitongId="+zixitongId,'',"dialogWidth=800px;dialogHeight=500px");
		if(typeof(datas) == 'undefined'){
		   }else{
			 var json1 = eval('(' + datas + ')');
			 document.getElementById("ZIXITONG").value = json1.id;
			 document.getElementById("XITONGNAME").value = json1.name;
		}
	}
	//选择故障模式
	function guzhangmoshi(){
		var   datas = window.showModalDialog("<%=request.getContextPath() %>/view/choose_guzhangmoshi.jsp",'',"dialogWidth=800px;dialogHeight=500px");
		if(typeof(datas) == 'undefined'){
		   }else{
			 var json1 = eval('(' + datas + ')');
			 document.getElementById("GUZHANGPATTERN").value = json1.id;
			 document.getElementById("GUZHANGPATTERNNAME").value = json1.name;
		}
	}

   </script>
 	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  	
		.formTableNew textarea{border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>
  </head>
  
  <body>
<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
        <input type="hidden" id="guzhangid" name="guzhangid" value="${guzhangku.ID }"/>
        <input type="hidden" id="flowtaskid" name="flowtaskid" value="${guzhangku.TASKID }"/>
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
  			<tr>
  				<td align="right">车型：</td><td align="left">
	  				<input type="hidden" id="CHEXING"  name="CHEXING" value="${guzhangku.CHEXING }">
	  				<input type="text" readonly=readonly id="CHXINGNAME"   name="CHXINGNAME" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.CHXINGNAME }" />
  				</td>
  			</tr>
  			<tr>
  				<td align="right">分类：</td><td align="left">
	  				<input type="hidden" id="FENLEI"  name="FENLEI" value="${guzhangku.FEILEI }">
	  				<input type="text" readonly=readonly id="FENLEINAME"   name="FENLEINAME" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.FENLEINAME }" />
  				</td>
  			</tr>
  			<tr>
  				<td align="right">子系统：</td>
  				<td align="left"><input type="hidden" id="ZIXITONG"  name="ZIXITONG" value="${guzhangku.ZIXITONG }">
  				   <input type="text" readonly=readonly id="XITONGNAME"   name="XITONGNAME" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.XITONGNAME }" />
  				   </td>
  			</tr>
  			<tr><td align="right">零部件：</td>
  				<td align="left"><input type="hidden" id="LINGBUJIAN"  name="LINGBUJIAN" value="${guzhangku.LINGBUJIAN }">
  				<input type="text" readonly=readonly id="LINGBUJIANNAME"   name="LINGBUJIANNAME" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.LINGBUJIANNAME }" />
  				</td>
  			</tr>
  			<tr>
	  			<td align="right">故障模式：</td>
	  			<td align="left"><input type="hidden" id="GUZHANGPATTERN"  name="GUZHANGPATTERN" value="${guzhangku.GUZHANGPATTERN }">
	  			<input type="text" readonly=readonly id="GUZHANGPATTERNNAME"   name="GUZHANGPATTERNNAME" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.GUZHANGPATTERNNAME }" />
	  			</td>
	  		</tr>
	  		<tr><td align="right">故障等级：</td>、
	  			<td align="left">
	  				<select id="GUZHANG_DENGJI" disabled="disabled" class='fselect' name="GUZHANG_DENGJI">
	  					<option <s:if test="guzhangku.GUZHANG_DENGJI==A">selected="selected"</s:if> value="A">A</option>
	  					<option <s:if test="guzhangku.GUZHANG_DENGJI==B">selected="selected"</s:if> value="B">B</option>
	  					<option <s:if test="guzhangku.GUZHANG_DENGJI==C">selected="selected"</s:if> value="C">C</option>
	  					<option <s:if test="guzhangku.GUZHANG_DENGJI==D">selected="selected"</s:if> value="D">D</option>
	  					<option <s:if test="guzhangku.GUZHANG_DENGJI==E">selected="selected"</s:if> value="E">E</option>
	  					<option <s:if test="guzhangku.GUZHANG_DENGJI==F">selected="selected"</s:if> value="F">F</option>
	  				</select>
	  			</td>
	  		</tr>
	  		<tr>
	  			<td align="right">行驶里程：</td>
	  			<td align="left">
	  			<input type="text" id="LICHENG"  readonly name="LICHENG" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.LICHENG }" />
	  			</td>
	  		</tr>
	  		<tr>
  				<td align="right">任务识别号：</td><td align="left">
	  				<input type="text" readonly=readonly id="shibiehao"   name="shibiehao" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.SHIBIEHAO }" />
  				</td>
  			</tr>
	  		<tr>
	  			<td align="right">故障发生时间：</td>
	  			<td align="left">
	  			<input type="text" id="GUZHANGFASHENGTIME"  readonly name="GUZHANGFASHENGTIME" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.GUZHANGFASHENGTIME }" />
	  			</td>
	  		</tr>
	  		<tr>
	  			<td align="right">记录人：</td>
	  			<td align="left">
	  			<input type="text" id="ADDUSER"  readonly name="ADDUSER" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${guzhangku.ADDUSER }" />
	  			</td>
	  		</tr>
  			<tr>
  			  <td align="right">故障图片：</td>
  			  <td align="left">
  			    <jsp:include page="../fileupload/attachment.jsp?id=${guzhangku.ID }&column=GUZHANG&show=y" ></jsp:include>
  			  </td>
  			  </tr>
 			<tr>
		    <td align="right"  >故障描述：</td>
		    <td colspan="3">
		    	<div class="div">
					<textarea rows="5" cols="100" id="guzhangmiaoshu" readonly name="guzhangmiaoshu" onkeydown="countlen1(this);" style="width: 250px;">${guzhangku.GUZHANG_MIAOSHU}</textarea>
				</div>	
		    </td>
		  </tr>
		</table>
		<table width="100%" border="0" align="center" class="formTableNew">
		  <tr>
			<td align="center">
		    	<input type="button" id="closeBtn" value="关 闭" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
	<!--表单结束-->
	</form>
 
  </body>
</html>
